<template>
  <div class="variableConfig">
    <div class="con">
         <div class="el-loading-mask" v-show="isMask">
                                    <div class="el-loading-spinner">
                                    <svg viewBox="25 25 50 50" class="circular">
                                        <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
                                    </svg>
                           </div>
         </div>
         <div class="lefttree">
            <el-scrollbar style="height:calc(100% - 5px);width: 100%;">
                <div :class="['leftitem',{'active':nowLeftRow == item.name}]" v-for="(item,index) in leftData" :key="index" @click="mytype='';getReadConFN(item)">
                    <img src="../../assets/btnImg/2.10.png" alt="">
                    <div class="myname">{{item.name2}}</div>
                </div>
            </el-scrollbar>
         </div>
         <div class="righttable">
            <div class="topbtn">
                <span></span>
                <div>
                    <el-button type="primary"  @click="tongbufn"  class="last-el-button">同步</el-button>
                </div>
            </div>
            <div class="mytable">
                <el-table id="demo" ref="table" height="calc(100% - 30px)" border  stripe :data="tableData" 
                    style="width: 100%">
                    <el-table-column label="序号" type="index" width="100" align="center"> </el-table-column>
                    <el-table-column prop="project" label="项目名称" min-width="170" ></el-table-column>
                    <el-table-column prop="version" label="版本" min-width="170" ></el-table-column>
                    <el-table-column prop="date" label="日期" min-width="160"></el-table-column>
                    <el-table-column prop="desc" label="描述"  ></el-table-column>
                    <el-table-column label="操作" width="250" align="center">
                    <template #default="{row}">
                        <div class="public-flex">
                         <span style="color:#368ed9;cursor: pointer;margin-right:28px" @click="openkongzhi(row)">控制区</span>
                         <span style="color:#368ed9;cursor: pointer;margin-right:28px" @click="openshebei(row,'设备列表')">设备列表</span>
                         <span style="color:#368ed9;cursor: pointer;" @click="editfn(row,'第一级')">修改</span>
                        </div>
                    </template>
                    </el-table-column>
                </el-table>
            </div>
         </div>
         <!-- 修改第一级 -->
         <el-dialog width="500px" draggable  title="修改"   v-model="editOneDio">
                    <div class="choicedio">
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">项目名称：</div>
                                <el-input v-model="editObj.projectName" placeholder="请输入项目名称"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">当前版本：</div>
                                <el-input v-model="editObj.version" placeholder="请输入版本号"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">选择日期：</div>
                                <el-date-picker
                                    v-model="editObj.date"
                                    type="date"
                                    format="YYYY/MM/DD"
                                    value-format="YYYY-MM-DD"
                                    placeholder="选择日期" style="height:36px">
                                </el-date-picker>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">版本描述：</div>
                                <el-input v-model="editObj.desc" placeholder="请输入版本描述"></el-input>
                            </div>
                         </div>
                    </div>
                    <div class="el-loading-mask" v-show="diaisMask">
                            <div class="el-loading-spinner">
                                    <svg viewBox="25 25 50 50" class="circular">
                                        <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
                                    </svg>
                            </div>
                     </div>
                      <template #footer>
                            <div class="dialog-footer">
                                 <el-button  @click="editOneDio = false" >取 消</el-button>
                                 <el-button  class="last-el-button" @click="addInvertersFn" type="primary">确 定</el-button>
                            </div>
                    </template> 
         </el-dialog>
         <!-- 控制区 -->
        <el-dialog width="1400px" draggable  title="控制区"   v-model="ControlArea">
                    <div class="choicedio kongzhiqudibdoiv">
                        <div class="dioaddbtn">
                            <span></span>
                            <el-button  class="last-el-button" @click="AddOperation('控制区')" type="primary">新增</el-button>
                        </div>
                        <el-table id="demo" ref="table" height="calc(100% - 30px)" border  stripe :data="ControlAreaData" 
                            style="width: 100%">
                            <el-table-column label="序号" type="index" width="60" align="center"> </el-table-column>
                            <el-table-column prop="name" label="名称"></el-table-column>
                            <el-table-column prop="capacity" label="有功容量(MW)"></el-table-column>
                            <el-table-column prop="r_capacity" label="无功容量(MW)"></el-table-column>
                            <el-table-column prop="system_impedance" label="系统阻抗"></el-table-column>
                            <el-table-column prop="state" label="状态"  width="80"></el-table-column>
                            <el-table-column prop="level" label="电压等级(V)"  width="110"></el-table-column>
                            <el-table-column prop="desc" label="描述"></el-table-column>
                            <el-table-column prop="enable" label="是否启用" width="80">
                                <template #default="{row}">
                                    <div class="public-flex">
                                       <span style="font-size:14px;color:red" v-show="row.enable === 0">禁用</span>
                                       <span style="font-size:14px;color:green" v-show="row.enable === 1">启用</span>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column label="操作" width="220" align="center" class-name="caozuo">
                            <template #default="{row}">
                                <div class="public-flex" style="display: flex; align-items: center;justify-content: center;">
                                <span style="color:#368ed9;cursor: pointer;font-size:14px;margin-right:16px;" @click="editfn(row,'控制区')">修改</span>
                                <span style="color:red;cursor: pointer;font-size:14px;margin-right:16px;" @click="delOperation(row,'控制区')">删除</span>
                                <div class="tongbu"  @click='row.isexit2 = true'>
                                    <div class="tongbudiv">
                                        <span style="color:#368ed9;cursor: pointer;font-size:14px;">更多</span>
                                    </div>
                                    <div :class="['myexit',{'exit-active':row.isexit2}]" @mouseleave='row.isexit2 = false'>
                                        <div class="exit-con">
                                            <div class="myexit-item" @click="openkongzhifangshi(row)">控制模式</div>
                                            <div class="myexit-item" @click="opengaoyace(row)">高压侧</div>
                                            <div class="myexit-item" @click="openfault(row)">事故列表</div>
                                            <div class="myexit-item"  @click="openkongzhiguankou(row)">关口(计量点)</div>
                                        </div>
                                    </div>
                                </div>
                                </div>
                            </template>
                            </el-table-column>
                        </el-table>
                    </div>
                    <div class="el-loading-mask" v-show="diaisMask">
                                    <div class="el-loading-spinner">
                                    <svg viewBox="25 25 50 50" class="circular">
                                        <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
                                    </svg>
                           </div>
                     </div>
                      <template #footer>
                    </template> 
        </el-dialog>
        <!-- 高压侧 -->
        <el-dialog width="1100px" draggable  title="高压侧"   v-model="gaoyaceflag">
                    <div class="choicedio">
                        <el-table id="demo" ref="table" height="calc(100% - 30px)" border  stripe :data="HVSideTableData" 
                            style="width: 100%">
                            <el-table-column prop="point" label="点号"  width="80" align="center"> </el-table-column>
                            <el-table-column prop="name" label="名称"></el-table-column>
                            <el-table-column prop="channelId" label="通道号"></el-table-column>
                            <el-table-column prop="deviceId" label="设备号"></el-table-column>
                            <el-table-column prop="type" label="类型" >
                                <template #default="{row}">
                                    <div class="public-flex">
                                    <span style="color:#1A1A1A;font-size:14px;" v-show="row.type === 0">遥信</span>
                                    <span style="color:#1A1A1A;font-size:14px;" v-show="row.type === 1">遥测</span>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column prop="dataType" label="数据类型" >
                                <template #default="{row}">
                                    <div class="public-flex">
                                    <span style="color:#1A1A1A;font-size:14px;" v-show="row.dataType == 0">float</span>
                                    <span style="color:#1A1A1A;font-size:14px;" v-show="row.dataType == 1">int</span>
                                    <span style="color:#1A1A1A;font-size:14px;" v-show="row.dataType == 2">bool</span>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column prop="pre" label="历史值" ></el-table-column>
                            <el-table-column prop="value" label="当前值" >
                                <template #default="{row}">
                                    <div class="public-flex">
                                       <span style="font-size:14px;color:green">{{row.value}}</span>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column prop="myts" label="时间" ></el-table-column>
                             <el-table-column prop="desc" label="描述" width="120"></el-table-column>
                            <el-table-column label="操作" width="120" align="center">
                                <template #default="{row}">
                                    <div class="public-flex">
                                    <span style="color:#368ed9;cursor: pointer;font-size:14px;" @click="editfn(row,'高压侧')">修改</span>
                                    </div>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                      <template #footer>
                    </template> 
        </el-dialog>
        <!-- 修改高压侧 -->
        <el-dialog width="500px" draggable  title="修改高压侧"    v-model="editGaoyace">
                    <div class="choicedio">
                        <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">点号：</div>
                                <el-input v-model="editObj.point" placeholder="请输入点号"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">通道号：</div>
                                <el-input v-model="editObj.channelId" placeholder="请输入通道号"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">设备号：</div>
                                <el-input v-model="editObj.deviceId" placeholder="请输入设备号"></el-input>
                            </div>
                         </div>
                 
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">名称：</div>
                                <el-input v-model="editObj.name" placeholder="请输入名称"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">描述：</div>
                                <el-input v-model="editObj.desc" placeholder="请输入描述"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">类型：</div>
                                <el-select v-model="editObj.type" placeholder="请选择">
                                    <el-option
                                    v-for="item in typeoptions"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                    </el-option>
                                </el-select>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">数据类型：</div>
                                <!-- <el-input v-model="editObj.dataType" placeholder="请输入数据类型"></el-input> -->
                                <el-select v-model="editObj.dataType" placeholder="请选择">
                                    <el-option
                                    v-for="item in datatypeoptions"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                    </el-option>
                                </el-select>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">历史值：</div>
                                <el-input v-model="editObj.pre" disabled></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">当前值：</div>
                                <el-input v-model="editObj.value" placeholder="请输入当前值"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">时间：</div>
                                <el-date-picker
                                    v-model="editObj.ts"
                                    type="date"
                                    format="YYYY/MM/DD"
                                    value-format="x"
                                    placeholder="选择日期" style="height:36px">
                                </el-date-picker>
                            </div>
                         </div>
                         
                         
                    </div>
                    <div class="el-loading-mask" v-show="diaisMask">
                            <div class="el-loading-spinner">
                                    <svg viewBox="25 25 50 50" class="circular">
                                        <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
                                    </svg>
                            </div>
                     </div>
                      <template #footer>
                            <div class="dialog-footer">
                                 <el-button  @click="editGaoyace = false" >取 消</el-button>
                                 <el-button  class="last-el-button" @click="addInvertersFn" type="primary">确 定</el-button>
                            </div>
                    </template> 
         </el-dialog>
        <!-- 事故列表 -->
        <el-dialog width="1100px" draggable  title="事故列表"   v-model="faultflag">
                    <div class="choicedio">
                        <el-table id="demo" ref="table" height="calc(100% - 30px)" border  stripe :data="faultTableData" 
                            style="width: 100%">
                            <el-table-column prop="point" label="点号"  width="60" align="center"> </el-table-column>
                            <el-table-column prop="name" label="名称"></el-table-column>
                            
                            <el-table-column prop="channelId" label="通道号"></el-table-column>
                            <el-table-column prop="deviceId" label="设备号"></el-table-column>
                            <el-table-column prop="type" label="类型" >
                                <template #default="{row}">
                                    <div class="public-flex">
                                    <span style="color:#1A1A1A;font-size:14px;" v-show="row.type === 0">遥信</span>
                                    <span style="color:#1A1A1A;font-size:14px;" v-show="row.type === 1">遥测</span>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column prop="dataType" label="数据类型" ></el-table-column>
                            <el-table-column prop="pre" label="历史值" ></el-table-column>
                            <el-table-column prop="value" label="当前值" >
                                <template #default="{row}">
                                    <div class="public-flex">
                                       <span style="font-size:14px;color:green">{{row.value}}</span>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column prop="myts" label="时间" ></el-table-column>
                            <el-table-column prop="desc" label="描述" width="120"></el-table-column>
                            <el-table-column label="操作" width="120" align="center">
                                <template #default="{row}">
                                    <div class="public-flex">
                                    <span style="color:#368ed9;cursor: pointer;font-size:14px;" @click="editfn(row,'事故')">修改</span>
                                    </div>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                      <template #footer>
                    </template> 
        </el-dialog>
        <!-- 修改事故列表 -->
        <el-dialog width="500px" draggable  title="修改事故"    v-model="editshigu">
                    <div class="choicedio">
                        <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">点号：</div>
                                <el-input v-model="editObj.point" placeholder="请输入点号"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">通道号：</div>
                                <el-input v-model="editObj.channelId" placeholder="请输入通道号"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">设备号：</div>
                                <el-input v-model="editObj.deviceId" placeholder="请输入设备号"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">名称：</div>
                                <el-input v-model="editObj.name" placeholder="请输入名称"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">描述：</div>
                                <el-input v-model="editObj.desc" placeholder="请输入描述"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">类型：</div>
                                <el-select v-model="editObj.type" placeholder="请选择">
                                    <el-option
                                    v-for="item in typeoptions"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                    </el-option>
                                </el-select>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">数据类型：</div>
                                <el-input v-model="editObj.dataType"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">历史值：</div>
                                <el-input v-model="editObj.pre" disabled></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">当前值：</div>
                                <el-input v-model="editObj.value" placeholder="请输入状态"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">时间：</div>
                                <el-date-picker
                                    v-model="editObj.ts"
                                    type="date"
                                    format="YYYY/MM/DD"
                                    value-format="x"
                                    placeholder="选择日期" style="height:36px">
                                </el-date-picker>
                            </div>
                         </div>
                         
                         
                    </div>
                    <div class="el-loading-mask" v-show="diaisMask">
                            <div class="el-loading-spinner">
                                    <svg viewBox="25 25 50 50" class="circular">
                                        <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
                                    </svg>
                            </div>
                     </div>
                      <template #footer>
                            <div class="dialog-footer">
                                 <el-button  @click="editshigu = false" >取 消</el-button>
                                 <el-button  class="last-el-button" @click="addInvertersFn" type="primary">确 定</el-button>
                            </div>
                    </template> 
         </el-dialog>
        <!-- 修改第二级(控制区) -->
         <el-dialog width="500px" draggable  :title="addroedit =='新增' ? '新增控制区' : '修改控制区'"    v-model="editKongZhiQu">
                    <div class="choicedio">
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">名称：</div>
                                <el-input v-model="editObj.name" placeholder="请输入名称"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">描述：</div>
                                <el-input v-model="editObj.desc" placeholder="请输入描述"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">有功容量(MW)：</div>
                                <el-input v-model="editObj.capacity" placeholder="请输入有功容量"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">无功容量(MW)：</div>
                                <el-input v-model="editObj.r_capacity" placeholder="请输入无功容量"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">系统阻抗：</div>
                                <el-input v-model="editObj.system_impedance" placeholder="请输入系统阻抗"></el-input>
                            </div>
                         </div>
                         
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">状态：</div>
                                <el-input v-model="editObj.state" placeholder="请输入状态"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">电压等级(V)：</div>
                                <el-input v-model="editObj.level" placeholder="请输入等级"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">是否启用：</div>
                                <el-select v-model="editObj.enable" placeholder="请选择">
                                    <el-option
                                    v-for="item in options"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                    </el-option>
                                </el-select>
                            </div>
                         </div>
                         
                    </div>
                    <div class="el-loading-mask" v-show="diaisMask">
                            <div class="el-loading-spinner">
                                    <svg viewBox="25 25 50 50" class="circular">
                                        <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
                                    </svg>
                            </div>
                     </div>
                      <template #footer>
                            <div class="dialog-footer">
                                 <el-button  @click="editKongZhiQu = false" >取 消</el-button>
                                 <el-button  class="last-el-button" @click="addInvertersFn" type="primary">确 定</el-button>
                            </div>
                    </template> 
         </el-dialog>
        <!-- 控制区--控制方式 -->
        <el-dialog width="1000px" draggable  title="控制模式"   v-model="controlMode">
                    <div class="choicedio">
                        <div class="dioaddbtn">
                            <span></span>
                            <el-button  class="last-el-button" @click="AddOperation('控制模式')" type="primary">新增</el-button>
                        </div>
                        <el-table id="demo" ref="table" height="calc(100% - 30px)" border  stripe :data="controlModeData" 
                            style="width: 100%">
                            <el-table-column label="序号" type="index" width="60" align="center"> </el-table-column>
                            <el-table-column prop="command_code" label="命令功能码"  ></el-table-column>
                            <el-table-column prop="state" label="状态"  ></el-table-column>
                            <el-table-column prop="desc" label="描述"  ></el-table-column>
                            <el-table-column prop="dev_list" label="关联的设备列表"  ></el-table-column>
                             <el-table-column label="操作" width="180" align="center">
                            <template #default="{row}">
                                <div class="public-flex">
                                <span style="color:#368ed9;cursor: pointer;font-size:14px;margin-right:12px" @click="openDevicefn(row)">设备列表</span>
                                <span style="color:#368ed9;cursor: pointer;font-size:14px;margin-right:12px" @click="editfn(row,'控制模式')">修改</span>
                                <span style="color:red;cursor: pointer;font-size:14px" @click="delOperation(row,'控制模式')">删除</span>
                                </div>
                            </template>
                            </el-table-column>
                        </el-table>
                    </div>
                    <div class="el-loading-mask" v-show="diaisMask">
                                    <div class="el-loading-spinner">
                                    <svg viewBox="25 25 50 50" class="circular">
                                        <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
                                    </svg>
                           </div>
                     </div>
                      <template #footer>
                    </template> 
        </el-dialog>
        <!-- 修改第三级(控制模式) -->
         <el-dialog width="500px" draggable  :title="addroedit =='新增' ? '新增控制模式' : '修改控制模式'"   v-model="editKongZhiMoshi">
                    <div class="choicedio">
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">命令功能码：</div>
                                <el-input v-model="editObj.command_code" placeholder="请输入命令功能码"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">状态：</div>
                                <el-input v-model="editObj.state" placeholder="请输入状态"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">描述：</div>
                                <el-input v-model="editObj.desc" placeholder="请输入描述"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">设备列表：</div>
                                <el-input v-model="editObj.dev_list" disabled></el-input>
                                <el-button  class="last-el-button" type="primary" @click="openshebei(tableData[0],'选择设备列表')" style="margin-left:6px">选择设备列表</el-button>
                            </div>
                         </div>
                    </div>
                    <div class="el-loading-mask" v-show="diaisMask">
                            <div class="el-loading-spinner">
                                    <svg viewBox="25 25 50 50" class="circular">
                                        <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
                                    </svg>
                            </div>
                     </div>
                      <template #footer>
                            <div class="dialog-footer">
                                 <el-button  @click="editKongZhiMoshi = false" >取 消</el-button>
                                 <el-button  class="last-el-button" @click="addInvertersFn" type="primary">确 定</el-button>
                            </div>
                    </template> 
         </el-dialog>
         <!-- 控制模型 -- 纯看设备列表-->
        <el-dialog width="1100px" draggable  title="控制模式(设备列表)"   v-model="kongzhimoshishebei">
                    <div class="choicedio">
                        <el-table id="demo" ref="table" height="calc(100% - 30px)" border  stripe :data="nowDeviceTableData" 
                            style="width: 100%">
                            <el-table-column label="序号" type="index" width="60" align="center"> </el-table-column>
                            <el-table-column prop="name" label="设备名称"></el-table-column>
                            <el-table-column prop="dev_id" label="设备序号"></el-table-column>
                            <el-table-column prop="ch_id" label="通道号"></el-table-column>
                            <el-table-column prop="dev_type" label="设备类型"></el-table-column>
                            <el-table-column prop="state" label="状态" ></el-table-column>
                             <el-table-column prop="control_protocol" label="控制协议" ></el-table-column>
                        </el-table>
                    </div>
                      <template #footer>
                    </template> 
        </el-dialog>

        <!-- 控制区--关口(计量点)-->
        <el-dialog width="1100px" draggable  title="关口(计量点)"   v-model="strategicPass">
                    <div class="choicedio">
                        <div class="dioaddbtn">
                            <span></span>
                            <el-button  class="last-el-button" @click="AddOperation('关口')" type="primary">新增</el-button>
                        </div>
                        <el-table id="demo" ref="table" height="calc(100% - 30px)" border  stripe :data="strategicPassData" 
                            style="width: 100%">
                            <el-table-column label="序号" type="index" width="60" align="center"> </el-table-column>
                            <el-table-column prop="desc" label="名称"  min-width="100"></el-table-column>
                            <el-table-column prop="name" label="描述"  min-width="200"></el-table-column>
                            <el-table-column prop="point" label="点号"  ></el-table-column>
                            <el-table-column prop="channelId" label="通道号"  ></el-table-column>
                            <el-table-column prop="deviceId" label="设备号"  ></el-table-column>
                            <el-table-column prop="value" label="当前值" align="center">
                                <template #default="{row}">
                                    <div class="public-flex">
                                       <span style="font-size:14px;color:green">{{row.value}}</span>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column prop="type" label="类型"  ></el-table-column>
                            <el-table-column label="操作" width="240" align="center">
                            <template #default="{row}">
                                <div class="public-flex">
                                <span style="color:#368ed9;cursor: pointer;font-size:14px;margin-right:12px" @click="editfn(row,'关口')">修改</span>
                                <span style="color:red;cursor: pointer;font-size:14px" @click="delOperation(row,'关口')">删除</span>
                                </div>
                            </template>
                            </el-table-column>
                        </el-table>
                    </div>
                    <div class="el-loading-mask" v-show="diaisMask">
                                    <div class="el-loading-spinner">
                                    <svg viewBox="25 25 50 50" class="circular">
                                        <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
                                    </svg>
                           </div>
                     </div>
                      <template #footer>
                    </template> 
        </el-dialog>
         <!-- 修改第三级(关口) -->
         <el-dialog width="500px" draggable  :title="addroedit =='新增' ? '新增关口' : '修改关口'"   v-model="editguankou">
                    <div class="choicedio">
                        <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">名称：</div>
                                <el-input v-model="editObj.desc" placeholder="请输入名称"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">描述：</div>
                                <el-input v-model="editObj.name" placeholder="请输入描述"></el-input>
                            </div>
                         </div>
                         
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">通道号：</div>
                                <el-input v-model="editObj.channelId" placeholder="请输入通道号"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">设备号：</div>
                                <el-input v-model="editObj.deviceId" placeholder="请输入设备号"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">点号：</div>
                                <el-input v-model="editObj.point" placeholder="请输入点号"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">类型：</div>
                                <el-input v-model="editObj.type" placeholder="请输入类型"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">当前值：</div>
                                <el-input v-model="editObj.value" placeholder="请输入当前值"></el-input>
                            </div>
                         </div>
                    </div>
                    <div class="el-loading-mask" v-show="diaisMask">
                            <div class="el-loading-spinner">
                                    <svg viewBox="25 25 50 50" class="circular">
                                        <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
                                    </svg>
                            </div>
                     </div>
                      <template #footer>
                            <div class="dialog-footer">
                                 <el-button  @click="editguankou = false" >取 消</el-button>
                                 <el-button  class="last-el-button" @click="addInvertersFn" type="primary">确 定</el-button>
                            </div>
                    </template> 
         </el-dialog>
         
        <!-- 设备列表 -->
        <el-dialog width="1300px" draggable  title="设备" v-model="devicelistDio">
                    <div class="choicedio">
                        <div class="dioaddbtn">
                            <span></span>
                            <el-button  class="last-el-button" @click="AddOperation('设备')" type="primary">新增</el-button>
                        </div>
                        <el-table id="demo" ref="multipleTable" height="calc(100% - 30px)" border  stripe :data="devicelistData" 
                        @selection-change="handleSelectionChange"
                            style="width: 100%">
                            <el-table-column type="selection" width="55" align="center" v-if="isXuanZeDevice =='选择'"></el-table-column>
                            <el-table-column label="序号" type="index" width="60" align="center"> </el-table-column>
                            <el-table-column prop="name" label="名称"  width="150"></el-table-column>
                            <el-table-column prop="ch_id" label="通道号"  width="100"></el-table-column>
                            <el-table-column prop="dev_id" label="设备序号"  width="100"></el-table-column>
                            <el-table-column prop="dev_type" label="设备类型"  width="100">
                                <template #default="{row}">
                                    <div class="public-flex">
                                    <span style="color:#1A1A1A;font-size:14px;" v-show="row.dev_type == 0">数采</span>
                                    <span style="color:#1A1A1A;font-size:14px;" v-show="row.dev_type == 1">逆变器</span>
                                    <span style="color:#1A1A1A;font-size:14px;" v-show="row.dev_type == 2">储能</span>
                                    <span style="color:#1A1A1A;font-size:14px;" v-show="row.dev_type == 3">svg</span>
                                    <span style="color:#1A1A1A;font-size:14px;" v-show="row.dev_type == 4">电容补偿柜</span>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column prop="pre" label="历史值"  width="100"></el-table-column>
                            <el-table-column prop="value" label="当前值"  align="center" width="100">
                                <template #default="{row}">
                                    <div class="public-flex">
                                       <span style="font-size:14px;color:green">{{row.value}}</span>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column prop="state" label="状态" width="100" ></el-table-column>
                            <el-table-column prop="enable" label="是否启用" width="100" align="center">
                                <template #default="{row}">
                                    <div class="public-flex">
                                      <span style="font-size:14px;color:red"   v-show="row.enable === 0">禁用</span>
                                       <span style="font-size:14px;color:green" v-show="row.enable === 1">启用</span>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column prop="capacity" label="有功容量" width="120"></el-table-column>
                            <el-table-column prop="r_capacity" label="无功容量" width="120"></el-table-column>
                            <el-table-column prop="unit" label="容量单位" width="80">
                                <template #default="{row}">
                                    <div class="public-flex">
                                      <span style="font-size:14px;" v-show="row.unit == 1">W(var)</span>
                                       <span style="font-size:14px;"  v-show="row.unit == 2">KW(kvr)</span>
                                       <span style="font-size:14px;"  v-show="row.unit == 3">MW(mvar) </span>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column prop="unit" label="容性为正" width="80">
                                <template #default="{row}">
                                    <div class="public-flex">
                                      <span style="font-size:14px;"   v-if="row.r_cap_isPositive">是</span>
                                       <span style="font-size:14px;color:red" v-else>否</span>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column prop="coefficient" label="有功系数" width="120"></el-table-column>
                            <el-table-column prop="r_coefficient" label="无功系数" width="120"></el-table-column>
                            <el-table-column prop="desc" label="备注" width="120"></el-table-column>
                            <el-table-column prop="control_protocol" label="控制协议"  width="100">
                                <template #default="{row}">
                                    <div class="public-flex">
                                      <span style="font-size:14px;"   v-show="row.control_protocol === 0">未知</span>
                                       <span style="font-size:14px;" v-show="row.control_protocol == 1">104</span>
                                       <span style="font-size:14px;" v-show="row.control_protocol == 2">modbus</span>
                                    </div>
                                </template>
                            </el-table-column>
                            <el-table-column prop="tss" label="时间"  width="100"></el-table-column>
                            <el-table-column prop="result_code" label="返回编码"  width="100"></el-table-column>
                            <el-table-column prop="result_desc" label="返回描述"  width="100"></el-table-column>
                            <el-table-column label="操作" width="300" align="center" v-if="isXuanZeDevice =='正常'" fixed="right">
                            <template #default="{row}">
                                <div class="public-flex">
                                <span style="color:#368ed9;cursor: pointer;margin-right:12px;font-size:14px" @click="opentelemetryMapping(row)">遥测映射</span>
                                <span style="color:#368ed9;cursor: pointer;margin-right:12px;font-size:14px" @click="openshebeiliebiao(row)">指令列表</span>
                                <span style="color:#368ed9;cursor: pointer;font-size:14px;margin-right:12px;" @click="editfn(row,'设备')">修改</span>
                                <span style="color:red;cursor: pointer;font-size:14px" @click="delOperation(row,'设备')">删除</span>
                                </div>
                            </template>
                            </el-table-column>
                        </el-table>
                    </div>
                    <div class="el-loading-mask" v-show="diaisMask">
                                    <div class="el-loading-spinner">
                                    <svg viewBox="25 25 50 50" class="circular">
                                        <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
                                    </svg>
                           </div>
                     </div>
                      <template #footer>
                                 <div class="dialog-footer" v-if="isXuanZeDevice =='选择'">
                                      <el-button  @click="devicelistDio = false" >取 消</el-button>
                                      <el-button  class="last-el-button" @click="quedingshebei" type="primary">确 定</el-button>
                                 </div>
                    </template>
                  
                      
                    
        </el-dialog>

        <!-- 修改第二级(设备列表) -->
        <el-dialog width="900px" draggable  :title="addroedit =='新增' ? '新增设备' : '修改设备'"   v-model="editDevice">
                    <div class="choicedio choicedio2">
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">名称：</div>
                                <el-input v-model="editObj.name" placeholder="请输入名称"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">通道号：</div>
                                <el-input v-model="editObj.channelId" placeholder="请输入通道号"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">设备序号：</div>
                                <el-input v-model="editObj.deviceId" placeholder="请输入设备序号"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">设备类型：</div>
                                <el-select v-model="editObj.deviceType" placeholder="请选择">
                                    <el-option
                                    v-for="item in deviceTypeOption"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                    </el-option>
                                </el-select>
                                <!-- <el-input v-model="editObj.deviceType" placeholder="请输入设备类型"></el-input> -->
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">状态：</div>
                                <el-input v-model="editObj.state" placeholder="请输入状态"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">是否启用：</div>
                               <el-select v-model="editObj.enable" placeholder="请选择">
                                    <el-option
                                    v-for="item in options"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                    </el-option>
                                </el-select>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">历史值：</div>
                                <el-input v-model="editObj.pre" placeholder="" disabled></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">当前值：</div>
                                <el-input v-model="editObj.value" placeholder="请输入当前值"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">有功容量：</div>
                                <el-input v-model="editObj.capacity" placeholder="请输入有功容量"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">无功容量：</div>
                                <el-input v-model="editObj.r_capacity" placeholder="请输入无功容量"></el-input>
                            </div>
                         </div>

                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">容量单位：</div>
                                <!-- <el-input v-model="editObj.unit" placeholder="请输入容量单位"></el-input> -->
                                <el-select v-model="editObj.unit" placeholder="请选择">
                                    <el-option
                                    v-for="item in unitOptions"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                    </el-option>
                                </el-select>
                            </div>
                         </div>
                         <!-- <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">单位枚举：</div>
                                <span style="font-size:16px;color:#9c9c10">{{editObj.unitPrompt}}</span>
                            </div>
                         </div> -->
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">有功系数：</div>
                                <el-input v-model="editObj.coefficient" placeholder="请输入有功系数"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">无功系数：</div>
                                <el-input v-model="editObj.r_coefficient" placeholder="请输入无功系数"></el-input>
                            </div>
                         </div>
                         
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">控制协议：</div>
                                
                                <el-select v-model="editObj.controlProtocol" placeholder="请选择">
                                    <el-option
                                    v-for="item in kongzhixieyi"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                    </el-option>
                                </el-select>
                                <!-- <el-input v-model="editObj.controlProtocol" placeholder="请输入控制协议"></el-input> -->
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">返回编码：</div>
                                <el-input v-model="editObj.resultCode" placeholder="请输入返回编码"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">返回描述：</div>
                                <el-input v-model="editObj.resultDesc" placeholder="请输入返回描述"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">容性为正：</div>
                                <el-select v-model="editObj.r_cap_isPositive" placeholder="请选择">
                                    <el-option
                                    v-for="item in isPositive"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                                    </el-option>
                                </el-select>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">时间：</div>
                                <el-date-picker
                                    v-model="editObj.date"
                                    type="date"
                                    format="YYYY/MM/DD"
                                    value-format="YYYY-MM-DD"
                                    placeholder="选择日期" style="height:36px">
                                </el-date-picker>
                            </div>
                         </div>
                          <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">备注：</div>
                                <el-input v-model="editObj.desc" placeholder="请输入备注"></el-input>
                            </div>
                         </div>
                    </div>
                    <div class="el-loading-mask" v-show="diaisMask">
                            <div class="el-loading-spinner">
                                    <svg viewBox="25 25 50 50" class="circular">
                                        <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
                                    </svg>
                            </div>
                     </div>
                      <template #footer>
                            <div class="dialog-footer">
                                 <el-button  @click="editDevice = false" >取 消</el-button>
                                 <el-button  class="last-el-button" @click="addInvertersFn" type="primary">确 定</el-button>
                            </div>
                    </template> 
        </el-dialog>

        <el-dialog width="1100px" draggable  title="设备列表"   v-model="shebieliebiao">
                    <div class="choicedio">
                        <div class="dioaddbtn">
                            <span></span>
                            <el-button  class="last-el-button" @click="AddOperation('设备命令')" type="primary">新增</el-button>
                        </div>
                        <el-table id="demo" ref="table" height="calc(100% - 30px)" border  stripe :data="shebieliebiaoData" 
                            style="width: 100%">
                            <el-table-column label="序号" type="index" width="60" align="center"> </el-table-column>
                            <el-table-column prop="command_code" label="命令功能码"></el-table-column>
                            <el-table-column prop="point" label="点号"  ></el-table-column>
                            <el-table-column prop="unit_type" label="调节类型"  ></el-table-column>
                            <el-table-column prop="register" label="寄存器"  ></el-table-column>
                            <el-table-column prop="register_type" label="寄存器类型"  ></el-table-column>
                            <el-table-column prop="command_type" label="指令类型"  ></el-table-column>
                            <el-table-column prop="desc" label="描述"  ></el-table-column>
                            <el-table-column label="操作" width="120" align="center" v-if="isXuanZeDevice =='正常'">
                            <template #default="{row}">
                                <div class="public-flex">
                                <span style="color:#368ed9;cursor: pointer;font-size:14px;margin-right:8px" @click="editfn(row,'设备命令')">修改</span>
                                <span style="color:red;cursor: pointer;font-size:14px" @click="delOperation(row,'设备命令')">删除</span>
                                </div>
                            </template>
                            </el-table-column>
                        </el-table>
                    </div>
                    <div class="el-loading-mask" v-show="diaisMask">
                                    <div class="el-loading-spinner">
                                    <svg viewBox="25 25 50 50" class="circular">
                                        <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
                                    </svg>
                           </div>
                     </div>
                      <template #footer>
                    </template> 
        </el-dialog>

        <!-- 修改第三级(设备命令) -->
        <el-dialog width="500px" draggable  :title="addroedit =='新增' ? '新增设备命令' : '修改设备命令'"   v-model="editDevicemingli">
                    <div class="choicedio">
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">命令功能码：</div>
                                <el-input v-model="editObj.command_code" placeholder="请输入命令功能码"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">描述：</div>
                                <el-input v-model="editObj.desc" placeholder="请输入描述"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">点号：</div>
                                <el-input v-model="editObj.point" placeholder="请输入点号"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">调节类型：</div>
                                <el-input v-model="editObj.unit_type" placeholder="请输入调节类型"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">寄存器点号：</div>
                                <el-input v-model="editObj.register" placeholder="请输入寄存器点号"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">寄存器类型：</div>
                                <el-input v-model="editObj.register_type" placeholder="请输入寄存器类型"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">指令类型：</div>
                                <el-input v-model="editObj.command_type" placeholder="请输入指令类型"></el-input>
                            </div>
                         </div>

                        
                    </div>
                    <div class="el-loading-mask" v-show="diaisMask">
                            <div class="el-loading-spinner">
                                    <svg viewBox="25 25 50 50" class="circular">
                                        <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
                                    </svg>
                            </div>
                     </div>
                      <template #footer>
                            <div class="dialog-footer">
                                 <el-button  @click="editDevicemingli = false" >取 消</el-button>
                                 <el-button  class="last-el-button" @click="addInvertersFn" type="primary">确 定</el-button>
                            </div>
                    </template> 
        </el-dialog>

        <!-- 遥测映射 -->
        <el-dialog width="900px" draggable  title="遥测映射"   v-model="telemetryMapping">
                    <div class="choicedio choicedio2 choicedio3">
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">有功功率(点号)：</div>
                                <el-input v-model="telemetryMappingData.active_power" placeholder="请输入有功功率(点号)"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">有功功率系数：</div>
                                <el-input v-model="telemetryMappingData.active_power_coef" placeholder="请输入有功功率系数"></el-input>
                            </div>
                         </div>

                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">无功功率(点号)：</div>
                                <el-input v-model="telemetryMappingData.reactive_power" placeholder="请输入无功功率(点号)"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">无功功率系数：</div>
                                <el-input v-model="telemetryMappingData.reactive_power_coef" placeholder="请输入无功功率系数"></el-input>
                            </div>
                         </div>

                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">当日发电量(点号)：</div>
                                <el-input v-model="telemetryMappingData.daily_power_generation" placeholder="请输入当日发电量(点号)"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">当日发电量系数：</div>
                                <el-input v-model="telemetryMappingData.daily_power_generation_coef" placeholder="请输入当日发电量系数"></el-input>
                            </div>
                         </div>

                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">当月发电量(点号)：</div>
                                <el-input v-model="telemetryMappingData.month_power_generation" placeholder="请输入当月发电量(点号)"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">当月发电量系数：</div>
                                <el-input v-model="telemetryMappingData.month_power_generation_coef" placeholder="请输入当月发电量系数"></el-input>
                            </div>
                         </div>

                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">当年发电量(点号)：</div>
                                <el-input v-model="telemetryMappingData.year_power_generation" placeholder="请输入当年发电量(点号)"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">当年发电量系数：</div>
                                <el-input v-model="telemetryMappingData.year_power_generation_coef" placeholder="请输入当年发电量系数"></el-input>
                            </div>
                         </div>

                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">累计发电量(点号)：</div>
                                <el-input v-model="telemetryMappingData.total_power_generation" placeholder="请输入累计发电量(点号)"></el-input>
                            </div>
                         </div>
                         <div class="infoitems">
                             <div class="items" style="width:100%">
                                <div class="leftname">累计发电量系数：</div>
                                <el-input v-model="telemetryMappingData.total_power_generation_coef" placeholder="请输入累计发电量系数"></el-input>
                            </div>
                         </div>
                        
                         
                         
                         
                    </div>
                    <div class="el-loading-mask" v-show="diaisMask">
                            <div class="el-loading-spinner">
                                    <svg viewBox="25 25 50 50" class="circular">
                                        <circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
                                    </svg>
                            </div>
                     </div>
                      <template #footer>
                            <div class="dialog-footer">
                                 <el-button  @click="telemetryMapping = false" >取 消</el-button>
                                 <el-button class="last-el-button"  @click="telemetryMappingCaozuo('修改')" type="primary">修 改</el-button>
                                 <!-- <el-button  class="last-el-button" @click="telemetryMappingCaozuo('删除')" type="primary" style="background-color:red !important;border-color:red !important">删 除</el-button> -->
                            </div>
                    </template> 
        </el-dialog>
        

    </div>
  </div>
</template>

<script>
import {getmodelreadJsonFileNames,getmodelreadJsonFile,editproject,delcontrolAreacontrolMode,addcontrolArea,deletecontrolArea,
editcontrolArea,editcontrolAreacontrolMode,addcontrolAreacontrolMode,editcontrolAreagate,addcontrolAreagate,editdeviceList,editdeviceCommands,
adddeviceCommands,adddeviceList,deletedeviceCommands,editPointMap,deletePointMap,deletedeviceList,deletecontrolAreagate,editcontrolAreaHVSide,editcontrolAreafault} from "../../api/groupTuningControl";
export default {


  data() {
    return {
       isexit2:false,
       options:[
        {
            value:1,
            label:"启用",
        },
        {
            value:0,
            label:"禁用",
        }
       ],
       typeoptions:[
        {
            value:0,
            label:"遥信",
        },
        {
            value:1,
            label:"遥测",
        }
       ],
       datatypeoptions:[
         {
            label:'float',
            value:0,
        },
         {
            label:'float',
            value:1,
        },
         {
            label:'bool',
            value:2,
        },
       ],
       unitOptions:[
        {
            label:'W(var)',
            value:1,
        },
        {
            label:'KW(kvr)',
            value:2,
        },
        {
            label:'MW(mvar)',
            value:3,
        },
       ],
       deviceTypeOption:[
         {
            label:'数采',
            value:0,
         },
         {
            label:'逆变器',
            value:1,
         },
         {
            label:'储能',
            value:2,
         },
         {
            label:'svg',
            value:3,
         },
         {
            label:'电容补偿柜',
            value:4,
         }
       ],
       kongzhixieyi:[
        {
            label:'未知',
            value:0
        },
        {
            label:'104',
            value:1
        },
        {
            label:'modbus',
            value:2
        },
       ],
       isMask:false,
       leftData:[],
       tableData:[],
       diaisMask:false,
       ControlArea:false,
       ControlAreaData:[],
       devicelistDio:false,
       devicelistData:[],
       controlMode:false,//控制方式
       controlModeData:[],
       strategicPass:false,//关口(计量点)
       strategicPassData:[],
       shebieliebiao:false,
       shebieliebiaoData:[],
       editOneDio:false,//修改第一级
       editObj:{
          projectName:"",//项目名称
          version:"",//版本号
          date:"",//日期
          enable:1,//是否启用
          level:"",//等级
          name:"",//控制区名称
          state:"",//状态
          desc:"",//描述
          capacity:"",//装机容量
          r_capacity:"",//无功容量
          command_code:"",//命令功能码
          dev_list:"",//设备列表
          channelId:"",//通道号
          deviceId:"",//设备号
          point:"",//点号
          type:"",//类型
          value:"",//当前值  
          coefficient:"",
          r_coefficient:"",
          deviceType:"",
          pre:"",
          controlProtocol:"",
          resultCode:"",
          resultDesc:"",
          unit_type:"",
          register:"",
          register_type:"",
          command_type:"",
          dataType:"",
          myname:"",
          mypre:"",
          system_impedance:"",//系统阻抗
          unit:"",//单位
          unitPrompt:"1-W(var), 2-KW(kvr), 3-MW(mvar)",
          r_cap_isPositive:true
       },
       isPositive:[
        {
            label:"是",
            value:true
        },
        {
            label:"否",
            value:false
        },
       ],
       nowLeftRow:"",
       mytype:"",
       nowLeftRowArr:{},
       editKongZhiQu:false,//修改控制区
       editDataList:{},
       editKongZhiMoshi:false,//修改控制模式
       nowKongZhiqu:{},//当前控制区,
       editguankou:false,//修改关口
       isXuanZeDevice:"选择",
       multipleSelection:[],
       editDevice:false,
       editDevicemingli:false,
       dangqianshebei:{},
       addroedit:"新增",
       nowDeviceTableData:[],
       kongzhimoshishebei:false,
       gaoyaceflag:false,//高压侧
       HVSideTableData:[],//高压侧表格数据
       editGaoyace:false,//修改高压侧
       faultflag:false,//事故
       editshigu:false,
       faultTableData:[],
       telemetryMapping:false,//遥测映射
       telemetryMappingData:{
            "active_power": "",
            "active_power_coef": "1",
            "reactive_power": "",
            "reactive_power_coef": "1",
            "daily_power_generation": "",
            "daily_power_generation_coef": "1",
            "month_power_generation": "",
            "month_power_generation_coef": "1",
            "year_power_generation": "",
            "year_power_generation_coef": "1",
            "total_power_generation": "",
            "total_power_generation_coef": "1"
        },


    };
  },

  mounted() {
    this.getList()
  },
  methods: {
    openDevicefn(row){
        // console.log("openDevicefn",row,this.tableData[0]);
        if(row.dev_list.length == 0){
            this.nowDeviceTableData = []
        }else {
            var arr1 = []
            var myindex = -1
            this.tableData[0].device_list.forEach(item => {
                 myindex = row.dev_list.findIndex(tt => tt == item.dev_id)
                 if(myindex != -1){
                    arr1.push(item)
                 }
            })
            this.nowDeviceTableData = arr1
        }
        
        this.kongzhimoshishebei = true
        
    },
    //同步
    tongbufn(){
         getmodelreadJsonFileNames().then(res => {
             if(res.code == 200){
                 this.$message({showClose: true,message: '同步成功',type: 'success'});
             }else {
                 this.$message({showClose: true,message: '同步失败',type: 'error'});
             }
         })
    },
    getList(){
        getmodelreadJsonFileNames().then(res => {
             if(res.code == 200){
                this.leftData = []
                 res.data.forEach(item => {
                    this.leftData.push({
                        name:item,
                        name2:item.replace('resources','设备模型').replace('.json','')
                    })
                 })
                //  this.leftData = res.data
                if(this.leftData.length != 0){
                        this.mytype = ""
                        this.getReadConFN(this.leftData[0])
                }
             }
        })
    },
    getReadConFN(row){
        // console.log("修改新增",row);
        this.nowLeftRowArr = row
        this.nowLeftRow = row.name
        var dataList = []
        this.tableData = []
        this.isMask = true
        getmodelreadJsonFile({'fileName':this.nowLeftRow}).then(res => {
            this.isMask = false
            this.diaisMask = false
            if(res.code == 200){
                var RESDATA = res.data
                this.tableData = [RESDATA]
                if(this.mytype == '控制区'){
                    this.openkongzhi(RESDATA)
                }else if(this.mytype == '控制模式'){
                    this.openkongzhi(RESDATA)
                    var myindex = this.ControlAreaData.findIndex(item => item.id == this.nowKongZhiqu.id)
                    this.openkongzhifangshi(this.ControlAreaData[myindex])
                }else if(this.mytype == '关口'){
                    this.openkongzhi(RESDATA)
                    var myindex = this.ControlAreaData.findIndex(item => item.id == this.nowKongZhiqu.id)
                    this.openkongzhiguankou(this.ControlAreaData[myindex])
                }else if(this.mytype == '设备'){
                    this.openshebei(RESDATA,'设备列表')
                }else if(this.mytype == '设备命令'){
                    this.openshebei(RESDATA,'设备列表')
                    var myindex = this.devicelistData.findIndex(item => item.id == this.dangqianshebei.id)
                    this.openshebeiliebiao(this.devicelistData[myindex])
                }else if(this.mytype == '高压侧'){
                    this.openkongzhi(RESDATA)
                    var myindex = this.ControlAreaData.findIndex(item => item.id == this.nowKongZhiqu.id)
                    this.opengaoyace(this.ControlAreaData[myindex])
                }else if(this.mytype == '事故'){
                    this.openkongzhi(RESDATA)
                    var myindex = this.ControlAreaData.findIndex(item => item.id == this.nowKongZhiqu.id)
                    this.openfault(this.ControlAreaData[myindex])
                }
            }
           
        })
    },
    //打开修改
    editfn(row,type){
        this.addroedit = '修改'
        this.editDataList = row
        // console.log("修改",row);
        this.mytype = type
        if(type == '第一级'){
            this.editObj.projectName = row.project
            this.editObj.version = row.version
            this.editObj.date = row.date
            this.editObj.desc = row.desc
            this.editOneDio = true
        }else if(type == '控制区'){
            this.editObj.name = row.name
            this.editObj.desc = row.desc
            this.editObj.state = row.state
            this.editObj.level = row.level
            this.editObj.enable = row.enable
            this.editObj.capacity = row.capacity
            this.editObj.r_capacity = row.r_capacity
            this.editObj.system_impedance = row.system_impedance
            this.editKongZhiQu = true
        }else if(type == '控制模式'){
            this.editObj.command_code = row.command_code
            this.editObj.desc = row.desc
            this.editObj.state = row.state
            this.editObj.dev_list = row.dev_list.join()
            this.editKongZhiMoshi = true
        }else if(type == '关口'){
            this.editObj.name = row.name
            this.editObj.channelId = row.channelId
            this.editObj.deviceId = row.deviceId
            this.editObj.point = row.point
            this.editObj.type = row.type
            this.editObj.desc = row.desc
            this.editObj.value = row.value
            this.editguankou = true
        }else if(type == '设备'){
            this.editObj.name = row.name
            this.editObj.channelId = row.ch_id
            this.editObj.deviceId = row.dev_id
            this.editObj.deviceType = row.dev_type
            this.editObj.state = row.state
            this.editObj.enable = row.enable
            this.editObj.pre = row.pre
            this.editObj.value = row.value
            this.editObj.desc = row.desc
            this.editObj.controlProtocol = row.control_protocol
            this.editObj.coefficient = row.coefficient
            this.editObj.r_coefficient = row.r_coefficient
            this.editObj.capacity = row.capacity
            this.editObj.r_capacity = row.r_capacity
            this.editObj.resultCode = row.result_code
            this.editObj.resultDesc = row.result_desc
            this.editObj.ts = row.ts
            this.editObj.unit = row.unit
            this.editObj.r_cap_isPositive = row.r_cap_isPositive
            this.editDevice = true
        }else if(type == '设备命令'){
            this.editObj.command_code = row.command_code
            this.editObj.desc = row.desc
            this.editObj.point = row.point
            this.editObj.unit_type = row.unit_type
            this.editObj.register = row.register
            this.editObj.register_type = row.register_type
            this.editObj.command_type = row.command_type
            this.editDevicemingli = true
        }else if(type == '高压侧'){
            this.editObj.name = row.name
            this.editObj.desc = row.desc
            this.editObj.point = row.point
            this.editObj.channelId = row.channelId
            this.editObj.deviceId = row.deviceId
            this.editObj.type = row.type
            this.editObj.dataType = row.dataType
            this.editObj.pre = row.pre
            this.editObj.mypre = JSON.parse(JSON.stringify(row.value))
            this.editObj.value = row.value
            this.editObj.ts = row.ts
            this.editObj.myname = row.myname
            this.editGaoyace = true
        }else if(type == '事故'){
            this.editObj.name = row.name
            this.editObj.desc = row.desc
            this.editObj.point = row.point
            this.editObj.channelId = row.channelId
            this.editObj.deviceId = row.deviceId
            this.editObj.type = row.type
            this.editObj.dataType = row.dataType
            this.editObj.pre = row.pre
            this.editObj.mypre = JSON.parse(JSON.stringify(row.value))
            this.editObj.value = row.value
            this.editObj.ts = row.ts
            this.editObj.myname = row.myname
            this.editshigu = true
        }
    },
    //确定修改
    addInvertersFn(){
        if(this.mytype == '第一级'){
            var dataList = new FormData()
            dataList.append("date",this.editObj.date)
            dataList.append("fileName",this.nowLeftRow)
            dataList.append("project",this.editObj.projectName)
            dataList.append("version",this.editObj.version)
            dataList.append("desc",this.editObj.desc)
            editproject(dataList).then(res => {
                 if(res.code == 200){
                    this.$message({showClose: true,message: '修改成功',type: 'success'});
                    this.getReadConFN(this.nowLeftRowArr)
                    this.editOneDio = false
                 }else {
                    this.$message({showClose: true,message: res.message ? res.message : '修改失败',type: 'error'});
                 }
            })
        }else if(this.mytype == '控制区'){
            //  this.nowLeftRow //文件名
            //  this.editDataList.id //id
            var dd = {
                "desc": this.editObj.desc,
                "enable": this.editObj.enable,
                "fileName": this.nowLeftRow,
                "id": this.editDataList.id,
                "level": this.editObj.level,
                "name": this.editObj.name,
                "nodeName": 'control_area',
                "state": this.editObj.state,
                "capacity":this.editObj.capacity,
                "RCapacity":this.editObj.r_capacity,
                'systemImpedance':this.editObj.system_impedance
            }
            if(this.addroedit == '新增'){
                dd.id = 1
                if(this.ControlAreaData.length != 0){
                    const maxId = Math.max(...this.ControlAreaData.map(item => item.id));
                    dd.id = (maxId+1)
                }
                addcontrolArea(dd).then(res => {
                    if(res.code == 200){
                     this.$message({showClose: true,message: '新增成功',type: 'success'});
                     this.getReadConFN(this.nowLeftRowArr)
                     this.editKongZhiQu = false
                    }else {
                        this.$message({showClose: true,message: res.message ? res.message : '新增失败',type: 'error'});
                    }
                })
            }else {
                editcontrolArea(dd).then(res => {
                    if(res.code == 200){
                     this.$message({showClose: true,message: '修改成功',type: 'success'});
                     this.getReadConFN(this.nowLeftRowArr)
                     this.editKongZhiQu = false
                    }else {
                        this.$message({showClose: true,message: res.message ? res.message : '修改失败',type: 'error'});
                    }
                })
            }
            
        }else if(this.mytype == '控制模式'){
            var dd = {
                "commandCode": this.editObj.command_code,
                "desc": this.editObj.desc,
                "dev_list": this.editObj.dev_list.split(","),
                "fileName": this.nowLeftRow,
                "id": this.editDataList.id,
                "nodeName": 'control_mode',
                "parentId":this.nowKongZhiqu.id,
                'parentName':"control_area",
                "state": this.editObj.state,
            }
            if(this.addroedit == '新增'){
                dd.id = 1
                if(this.controlModeData.length != 0){
                    const maxId = Math.max(...this.controlModeData.map(item => item.id));
                    dd.id = (maxId+1)
                }
                addcontrolAreacontrolMode(dd).then(res => {
                    if(res.code == 200){
                        this.getReadConFN(this.nowLeftRowArr)
                        this.$message({showClose: true,message: '新增成功',type: 'success'});
                        this.editKongZhiMoshi = false
                    }else {
                        this.$message({showClose: true,message: res.message ? res.message : '新增失败',type: 'error'});
                    }
                })
            }else {
                editcontrolAreacontrolMode(dd).then(res => {
                    if(res.code == 200){
                        this.getReadConFN(this.nowLeftRowArr)
                        this.$message({showClose: true,message: '修改成功',type: 'success'});
                        this.editKongZhiMoshi = false
                    }else {
                        this.$message({showClose: true,message: res.message ? res.message : '修改失败',type: 'error'});
                    }
                })
            }
            
        }else if(this.mytype == '关口'){
            var dd = {
                "baseNodeName": this.editObj.name,
                "channelId": Number(this.editObj.channelId),
                "deviceId": Number(this.editObj.deviceId),
                "fileName": this.nowLeftRow,
                "desc": this.editObj.desc,
                "parentId": this.nowKongZhiqu.id,
                "parentName": "control_area",
                "point":Number(this.editObj.point),
                "twoNodeName": "gate",
                "type": Number(this.editObj.type),
                "value": this.editObj.value
            }
            if(this.addroedit == '新增'){
                addcontrolAreagate(dd).then(res => {
                    if(res.code == 200){
                        this.getReadConFN(this.nowLeftRowArr)
                        this.$message({showClose: true,message: '新增成功',type: 'success'});
                        this.editguankou = false
                    }else {
                        this.$message({showClose: true,message: res.message ? res.message : '新增失败',type: 'error'});
                    }
                })
            }else {
                editcontrolAreagate(dd).then(res => {
                    if(res.code == 200){
                        this.getReadConFN(this.nowLeftRowArr)
                        this.$message({showClose: true,message: '修改成功',type: 'success'});
                        this.editguankou = false
                    }else {
                        this.$message({showClose: true,message: res.message ? res.message : '修改失败',type: 'error'});
                    }
                })
            }
            
        }else if(this.mytype == '设备'){
            var dd = {
                capacity:this.editObj.capacity,
                rCapacity:this.editObj.r_capacity,
                "channelId": this.editObj.channelId,
                "controlProtocol": this.editObj.controlProtocol,
                "coefficient": this.editObj.coefficient,
                "rCoefficient": this.editObj.r_coefficient,
                "desc": this.editObj.desc,
                "deviceId": this.editObj.deviceId,
                "deviceType": this.editObj.deviceType,
                "enable": this.editObj.enable,
                "fileName": this.nowLeftRow,
                "id": this.editDataList.id,
                "name": this.editObj.name,
                "parentName": "device_list",
                "pre": this.editObj.pre == "" ? this.editObj.value : this.editObj.pre,
                "resultCode": this.editObj.resultCode,
                "resultDesc": this.editObj.resultDesc,
                "state": this.editObj.state,
                "ts": this.editObj.date,
                'unit':this.editObj.unit,
                'rCapIsPositive':this.editObj.r_cap_isPositive,
                "value": this.editObj.value
            }
            if(this.addroedit == '新增'){
                dd.id = 1
                if(this.devicelistData.length != 0){
                    const maxId = Math.max(...this.devicelistData.map(item => item.id));
                    dd.id = (maxId+1)
                }
                adddeviceList(dd).then(res => {
                    if(res.code == 200){
                        this.getReadConFN(this.nowLeftRowArr)
                        this.$message({showClose: true,message: '新增成功',type: 'success'});
                        this.editDevice = false
                    }else {
                        this.$message({showClose: true,message: res.message ? res.message : '新增失败',type: 'error'});
                    }
                })
            }else {
                editdeviceList(dd).then(res => {
                    if(res.code == 200){
                        this.getReadConFN(this.nowLeftRowArr)
                        this.$message({showClose: true,message: '修改成功',type: 'success'});
                        this.editDevice = false
                    }else {
                        this.$message({showClose: true,message: res.message ? res.message : '修改失败',type: 'error'});
                    }
                })
            }
             
        }else if(this.mytype == '设备命令'){
            var dd = {
                "commandCode": this.editObj.command_code,
                "commandType": this.editObj.command_type,
                "desc": this.editObj.desc,
                "fileName": this.nowLeftRow,
                "id": this.editDataList.id,
                "nodeName": "commands",
                "parentId": this.dangqianshebei.id,
                "parentName": "device_list",
                "point": this.editObj.point,
                "register": this.editObj.register,
                "registerType": this.editObj.register_type,
                "unitType": this.editObj.unit_type
            }
            if(this.addroedit == '新增'){
                dd.id = 1
                if(this.shebieliebiaoData.length != 0){
                    const maxId = Math.max(...this.shebieliebiaoData.map(item => item.id));
                    dd.id = (maxId+1)
                }
                adddeviceCommands(dd).then(res => {
                    if(res.code == 200){
                        this.getReadConFN(this.nowLeftRowArr)
                        this.$message({showClose: true,message: '新增成功',type: 'success'});
                        this.editDevicemingli = false
                    }else {
                        this.$message({showClose: true,message: res.message ? res.message : '新增失败',type: 'error'});
                    }
                })
            }else {
                editdeviceCommands(dd).then(res => {
                    if(res.code == 200){
                        this.getReadConFN(this.nowLeftRowArr)
                        this.$message({showClose: true,message: '修改成功',type: 'success'});
                        this.editDevicemingli = false
                    }else {
                        this.$message({showClose: true,message: res.message ? res.message : '修改失败',type: 'error'});
                    }
                })
            }
             
        }else if(this.mytype == '高压侧'){
            var dd = {
                "dataNodeName": this.editObj.myname,
                "channelId": this.editObj.channelId,
                "dataType": this.editObj.dataType,
                "desc": this.editObj.desc,
                "deviceId": this.editObj.deviceId,
                "fileName": this.nowLeftRow,
                "name": this.editObj.name,
                "nodeName":'HVSide',
                "parentId": this.nowKongZhiqu.id,
                "parentName": 'control_area',
                "point": this.editObj.point,
                "pre": this.editObj.mypre,
                "ts":this.editObj.ts,
                "type": this.editObj.type,
                "value": this.editObj.value
            }
            if(this.editObj.mypre == this.editObj.value){
                 dd.pre = this.editObj.pre
            }
            editcontrolAreaHVSide(dd).then(res => {
                if(res.code == 200){
                    this.getReadConFN(this.nowLeftRowArr)
                    this.$message({showClose: true,message: '修改成功',type: 'success'});
                    this.editGaoyace = false
                }else {
                    this.$message({showClose: true,message: res.message ? res.message : '修改失败',type: 'error'});
                }
            })
        }else if(this.mytype == '事故'){
            var dd = {
                "dataNodeName": this.editObj.myname,
                "channelId": this.editObj.channelId,
                "dataType": this.editObj.dataType,
                "desc": this.editObj.desc,
                "deviceId": this.editObj.deviceId,
                "fileName": this.nowLeftRow,
                "name": this.editObj.name,
                "nodeName":'fault',
                "parentId": this.nowKongZhiqu.id,
                "parentName": 'control_area',
                "point": this.editObj.point,
                "pre": this.editObj.mypre,
                "ts":this.editObj.ts,
                "type": this.editObj.type,
                "value": this.editObj.value
            }
            if(this.editObj.mypre == this.editObj.value){
                 dd.pre = this.editObj.pre
            }
            editcontrolAreafault(dd).then(res => {
                if(res.code == 200){
                    this.getReadConFN(this.nowLeftRowArr)
                    this.$message({showClose: true,message: '修改成功',type: 'success'});
                    this.editshigu = false
                }else {
                    this.$message({showClose: true,message: res.message ? res.message : '修改失败',type: 'error'});
                }
            })
        }
    },
    //打开控制区
    openkongzhi(row){
        // console.log("接收控制区",row);
        this.ControlAreaData = row.control_area
        this.ControlAreaData.forEach(item => item.isexit2 = false)
        // isexit2
        this.ControlArea = true
    },
    //打开控制模式
    openkongzhifangshi(row){
        this.nowKongZhiqu = row
        this.controlModeData = row.control_mode
        this.controlMode = true
    },
    //打开事故列表
    openfault(row){
        this.nowKongZhiqu = row
        var RES = row.fault
        var datalist = []
        for(let key in RES){
            datalist.push({
                channelId:RES[key].channelId,
                deviceId:RES[key].deviceId,
                point:RES[key].point,
                myname:key,
                type:RES[key].type,
                dataType:RES[key].dataType,
                pre:RES[key].pre,
                value:RES[key].value,
                ts:RES[key].ts,
                myts:this.timerfn(RES[key].ts),
                name:RES[key].name,
                desc:RES[key].desc,
            })
        }
        this.faultTableData = datalist
        this.faultflag = true
    },
    //打开高压侧
    opengaoyace(row){
        this.nowKongZhiqu = row
        var RES = row.HVSide
        var datalist = []
        for(let key in RES){
            datalist.push({
                channelId:RES[key].channelId,
                myname:key,
                deviceId:RES[key].deviceId,
                point:RES[key].point,
                type:RES[key].type,
                dataType:RES[key].dataType,
                pre:RES[key].pre,
                value:RES[key].value,
                ts:RES[key].ts,
                myts:this.timerfn(RES[key].ts),
                name:RES[key].name,
                desc:RES[key].desc,
            })
        }
        this.HVSideTableData = datalist
        this.gaoyaceflag = true
    },
    //打开关口计量点
    openkongzhiguankou(row){
        this.nowKongZhiqu = row
        // this.strategicPassData = row.gate
        var RES = row.gate
        var datalist = []
        for(let key in RES){
            datalist.push({
                name:key,
                channelId:RES[key].channelId,
                deviceId:RES[key].deviceId,
                desc:RES[key].desc,
                point:RES[key].point,
                type:RES[key].type,
                value:RES[key].value,
            })
            // console.log("循环",key,RES[key]);
        }
        this.strategicPassData = datalist
        this.strategicPass = true
    },
    //打开设备列表
    openshebei(row,type){
        if(type == '设备列表'){
         this.isXuanZeDevice = '正常'
        }else {
            this.isXuanZeDevice = '选择'
        }
        this.devicelistData = row.device_list
        this.devicelistData.forEach(item => {
            item.tss = this.timerfn(item.ts)
        })
        this.devicelistDio = true
        this.$nextTick(() => {
            if(this.editObj.dev_list != ""){
                var arr1 = this.editObj.dev_list.split(",")
                var myindex = -1
                arr1.forEach(item => {
                     myindex = this.devicelistData.findIndex(tt => tt.dev_id == item)
                     if(myindex != -1){
                        this.$refs.multipleTable.toggleRowSelection(this.devicelistData[myindex])
                     }
                })

            }else {
                 this.$refs.multipleTable.clearSelection()
            }
        })
    },
    //处理时间戳
    timerfn(value){
        if (value === "" || value === 0) {
          return ""
        }
        let date = new Date(value);
        let Y = date.getFullYear() + '-';
        let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
        let D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';

        let h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':';
        let m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':';
        let s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
        let strDate = Y + M + D;
        return strDate
    },
    handleSelectionChange(val) {
        this.multipleSelection = val;
    },
    quedingshebei(){
        if(this.multipleSelection.length == 0){
            this.$message({showClose: true,message: '请选择设备',type: 'warning'});
            return
        }
        var ress = []
        this.multipleSelection.forEach(item => {
            ress.push(item.dev_id)
        })
        this.editObj.dev_list = ress.join()
        this.devicelistDio = false
       
    },
    //打开设备指令
    openshebeiliebiao(row){
        this.dangqianshebei = row
        this.shebieliebiaoData = row.commands
        this.shebieliebiao = true
    },
    //新增操作
    AddOperation(type){
       this.addroedit = '新增'
       this.mytype = type
       if(type == '设备命令'){
          this.editObj.command_code = ""
          this.editObj.desc = ""
          this.editObj.point = ""
          this.editObj.unit_type = "" 
          this.editObj.register = ""
          this.editObj.register_type = "" 
          this.editObj.command_type = ""
          this.editObj.system_impedance = ""
          this.editDevicemingli = true
       }else if(type == '设备'){
          this.editObj.name = ""
          this.editObj.channelId = ""
          this.editObj.deviceId = ""
          this.editObj.deviceType = ""
          this.editObj.state = ""
          this.editObj.enable = 1
          this.editObj.pre = ""
          this.editObj.value = ""
          this.editObj.desc = ""
          this.editObj.controlProtocol = ""
          this.editObj.resultCode = ""
          this.editObj.resultDesc = ""
          this.editObj.coefficient = ""
          this.editObj.r_coefficient = ""
          this.editObj.capacity = ""
          this.editObj.r_capacity = ""
          this.editObj.unit = ""
          this.editObj.r_cap_isPositive = true
          this.editObj.date = ""
          this.editDevice = true
       }else if(type == '关口'){
            this.editObj.name = ""
            this.editObj.channelId = ""
            this.editObj.deviceId = ""
            this.editObj.point = ""
            this.editObj.type = ""
            this.editObj.value = ""
            this.editguankou = true
       }else if(type == '控制模式'){
            this.editObj.command_code = ""
            this.editObj.desc = ""
            this.editObj.state = ""
            this.editObj.dev_list = ""
            this.editKongZhiMoshi = true
       }else if(type == '控制区'){
            this.editObj.name = ""
            this.editObj.desc = ""
            this.editObj.state = ""
            this.editObj.level = ""
            this.editObj.enable = 0
            this.editObj.capacity = ""
            this.editObj.r_capacity = ""
            this.editObj.system_impedance = ""
            this.editKongZhiQu = true
       }
    },
    //删除操作
    delOperation(row,type){
         this.$confirm(`是否要删除此项`,'提示',{
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
               this.mytype = type
               if(type == '设备命令'){
                  var dd = {
                        "fileName": this.nowLeftRow,
                        "id": row.id,
                        "nodeName": 'commands',
                        "parentId": this.dangqianshebei.id,
                        "parentName": "device_list"
                  }
                  deletedeviceCommands(dd).then(res => {
                     if(res.code == 200){
                            this.getReadConFN(this.nowLeftRowArr)
                            this.$message({showClose: true,message: '删除成功',type: 'success'});
                        }else {
                            this.$message({showClose: true,message: res.message ? res.message : '删除失败',type: 'error'});
                        }
                  })
               }else if(type == '设备'){
                  
                  var dd = {
                    "fileName": this.nowLeftRow,
                    "id": row.id,
                    "parentName": "device_list"
                  }
                  var arr1 = []
                  this.tableData.forEach(item => {
                      item.control_area.forEach(tt => {
                         tt.control_mode.forEach(it => {
                             arr1 = arr1.concat(it.dev_list)
                         })
                      })
                  })
                  var arr2 = arr1.filter(item => item == dd.id)
                  if(arr2.length != 0){
                     this.$message({showClose: true,message: '该设备以被控制模式所绑定，不可删除，需要删除就先解绑控制模式',type: 'warning'});
                     return
                  }
                  deletedeviceList(dd).then(res => {
                      if(res.code == 200){
                        this.getReadConFN(this.nowLeftRowArr)
                        this.$message({showClose: true,message: '删除成功',type: 'success'});
                    }else {
                        this.$message({showClose: true,message: res.message ? res.message : '删除失败',type: 'error'});
                    }
                  })
               }else if(type == '关口'){
                  var dd = {
                        "baseNodeName": row.name,
                        "fileName": this.nowLeftRow,
                        "parentId": this.nowKongZhiqu.id,
                        "parentName": "control_area",
                        "twoNodeName": "gate"
                  }
                  deletecontrolAreagate(dd).then(res => {
                    if(res.code == 200){
                        this.getReadConFN(this.nowLeftRowArr)
                        this.$message({showClose: true,message: '删除成功',type: 'success'});
                    }else {
                        this.$message({showClose: true,message: res.message ? res.message : '删除失败',type: 'error'});
                    }
                  })
               }else if(type == '控制模式'){
                  var dd = {
                    "fileName": this.nowLeftRow,
                    "id": row.id,
                    "nodeName": 'control_mode',
                    "parentId":this.nowKongZhiqu.id,
                    'parentName':"control_area",
                  }
                  delcontrolAreacontrolMode(dd).then(res => {
                    if(res.code == 200){
                        this.getReadConFN(this.nowLeftRowArr)
                        this.$message({showClose: true,message: '删除成功',type: 'success'});
                    }else {
                        this.$message({showClose: true,message: res.message ? res.message : '删除失败',type: 'error'});
                    }
                  })
               }else if(type == '控制区'){
                   var dd = {
                     	"fileName": this.nowLeftRow,
                        "id": row.id,
                        "nodeName": "control_area"
                   }
                   deletecontrolArea(dd).then(res => {
                        if(res.code == 200){
                          this.getReadConFN(this.nowLeftRowArr)
                          this.$message({showClose: true,message: '删除成功',type: 'success'});
                        }else {
                          this.$message({showClose: true,message: res.message ? res.message : '删除失败',type: 'error'});
                        }
                   })
               }
            }).catch(() => {
              // ...
            });
        
    },
    //打开遥测映射
    opentelemetryMapping(row){
        // console.log("遥测映射表",row)
        this.dangqianshebei = row
        this.telemetryMappingData = row.point_map
        this.telemetryMapping = true
    },
    //修改/删除遥测映射
    telemetryMappingCaozuo(type){
        this.mytype = '设备'
        if(type == '修改'){
            this.telemetryMappingData.fileName = this.nowLeftRow
            this.telemetryMappingData.nodeName = 'point_map'
            this.telemetryMappingData.parentId = this.dangqianshebei.id
            this.telemetryMappingData.parentName = 'device_list'
            editPointMap(this.telemetryMappingData).then(res => {
                //  console.log("修改",res);
                 if(res.code == 200){
                    this.telemetryMapping = false
                     this.getReadConFN(this.nowLeftRowArr)
                     this.$message({showClose: true,message: '修改成功',type: 'success'});
                 }else {
                     this.$message({showClose: true,message: res.message ? res.message : '修改失败',type: 'error'});
                 }
            })
        }else {
            this.$confirm(`是否要删除此遥测映射吗？`,'提示',{
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
                var dd = {
                    "fileName": this.nowLeftRow,
                    "nodeName": 'point_map',
                    "parentId": this.dangqianshebei.id,
                    "parentName": 'device_list'
                }
                deletePointMap(dd).then(res => {
                    if(res.code == 200){
                        this.telemetryMapping = false
                     this.getReadConFN(this.nowLeftRowArr)
                     this.$message({showClose: true,message: '删除成功',type: 'success'});
                 }else {
                     this.$message({showClose: true,message: res.message ? res.message : '删除失败',type: 'error'});
                 }
                })
             }).catch(() => {
              // ...
            });
        }
    },
  },
};
</script>
<style lang="scss" scoped>
:deep(.el-table--enable-row-hover .el-table__body tr:hover>td.el-table__cell){
    z-index: 9999;
}
    .variableConfig {
         width: 100%;
         height: 100%;
         :deep(.kongzhiqudibdoiv .el-table .cell){
            overflow: visible !important;
         }
         .tongbu {
            // width: 64px;
            height: 24px;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            cursor: pointer;
            
         }
         .myexit {
        width: 120px;
        // background-color: red;
        position: absolute;
        top: 0px;
        right: 0px;
        padding-top: 43px;
        z-index: 9999;
        //  box-shadow: 0 4px 24px 0 rgba(153,153,153,0.3);
        //  padding: 8px;
        display: none;

        &.exit-active {
          display: block;
        }

        .exit-con {
          background: #fff;
          box-shadow: 0 4px 24px 0 rgba(153, 153, 153, 0.3);
          padding: 8px;
          border-radius: 4px;
          .myexit-item {
             display: flex;
             align-items: center;
             justify-content: center;
          }

        }

        .myexit-item {
          width: 104px;
          height: 36px;
          color: #1A1A1A;
          display: flex;
          align-items: center;
          cursor: pointer;
          //  padding-left: 10px;
          color: #1A1A1A;
          box-sizing: border-box;
          border-radius: 4px;
          font-size: 13px;

          &:hover {
            border: 1px solid #3C89F2;
            background-color: #E7F0FF;
          }
        }

        .quxiao {
          border-top: 0px;
        }
          }
          .tongbu {
         .tongbudiv {
          display: flex;
          align-items: center;
          justify-content: center;
        }
        .myexit {
           right: -48px;
           top: -15px;
        }
      }
         .leftname {
             min-width: 98px !important;
             text-align: right;
         }
         .tips {
             margin-left: 130px;
             color: red;
         }
         .con {
             width: 100%;
             height: 100%;
             display: flex;
             position: relative;
             .lefttree {
                 width: 280px;
                 height: 100%;
                 background-color: #fff;
                 margin-right: 8px;
                 padding: 12px;
                 box-sizing: border-box;
                 .leftitem {
                     width: 100%;
                     height: 38px;
                     display: flex;
                     align-items: center;
                     padding-left: 12px;
                     box-sizing: border-box;
                     border: 1px solid #EBEBEB;
                     border-radius: 4px;
                     cursor: pointer;
                     margin-bottom: 12px;
                     img {
                        width: 20px;
                        height: 20px;
                         margin-right: 4px;
                     }
                     &.active {
                         background-color: #2178f1 !important;
                        color: #fff !important;
                     }
                     &:hover{
                        background-color: #bcddff;
                        color: #1A1A1A;
                     }
                 }
             }
             .righttable {
                 width: calc(100% - 288px);
                 height: 100%;
                 background-color: #fff;
                 padding: 12px;
                 box-sizing: border-box;
                 .topbtn {
                 display: flex;
                 align-items: center;
                 justify-content: space-between;
                 margin-bottom: 12px;
              }
              
              .mytable {
                 width: 100%;
                 height: calc(100% - 42px);
                 .public-flex {
                     span {
                         font-size: 14px;
                     }
                 }
              }
             }
         }
         :deep(.infoitems .el-icon svg){
               top: 0px !important;
         }
         .choicedio {
             height: 500px;
         }
         .dioaddbtn {
             display: flex;
             align-items: center;
             justify-content: space-between;
             margin-bottom: 8px;
         }
         .choicedio2 {
             height: 520px;
             display: flex;
             flex-wrap: wrap;
             .infoitems {
                 width: calc(50% - 8px);
             }
         }
         .choicedio3 .leftname {
             width: 120px !important;
             min-width: 120px !important;
         }
    }
</style>